<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>SQL list</title>
<style type="text/css">
	form{
		margin: 10px;
	}
	body{
		font-size: 12px;
	}
	textarea {
		font-size: 12px;
	}
</style>
<script type="text/javascript" src="<%=request.getContextPath()%>/static/js/jquery-1.8.1.js"></script>
<script type="text/javascript">
function formatJson(json, options) {
	var reg = null,
		formatted = '',
		pad = 0,
		PADDING = '    '; // one can also use '\t' or a different number of spaces
 
	// optional settings
	options = options || {};
	// remove newline where '{' or '[' follows ':'
	options.newlineAfterColonIfBeforeBraceOrBracket = (options.newlineAfterColonIfBeforeBraceOrBracket === true) ? true : false;
	// use a space after a colon
	options.spaceAfterColon = (options.spaceAfterColon === false) ? false : true;
 
	// begin formatting...
	if (typeof json !== 'string') {
		// make sure we start with the JSON as a string
		json = JSON.stringify(json);
	} else {
		// is already a string, so parse and re-stringify in order to remove extra whitespace
		json = JSON.parse(json);
		json = JSON.stringify(json);
	}
 
	// add newline before and after curly braces
	reg = /([\{\}])/g;
	json = json.replace(reg, '\r\n$1\r\n');
 
	// add newline before and after square brackets
	reg = /([\[\]])/g;
	json = json.replace(reg, '\r\n$1\r\n');
 
	// add newline after comma
	reg = /(\,)/g;
	json = json.replace(reg, '$1\r\n');
 
	// remove multiple newlines
	reg = /(\r\n\r\n)/g;
	json = json.replace(reg, '\r\n');
 
	// remove newlines before commas
	reg = /\r\n\,/g;
	json = json.replace(reg, ',');
 
	// optional formatting...
	if (!options.newlineAfterColonIfBeforeBraceOrBracket) {			
		reg = /\:\r\n\{/g;
		json = json.replace(reg, ':{');
		reg = /\:\r\n\[/g;
		json = json.replace(reg, ':[');
	}
	if (options.spaceAfterColon) {			
		reg = /\:/g;
		json = json.replace(reg, ': ');
	}
 
	$.each(json.split('\r\n'), function(index, node) {
		var i = 0,
			indent = 0,
			padding = '';
 
		if (node.match(/\{$/) || node.match(/\[$/)) {
			indent = 1;
		} else if (node.match(/\}/) || node.match(/\]/)) {
			if (pad !== 0) {
				pad -= 1;
			}
		} else {
			indent = 0;
		}
 
		for (i = 0; i < pad; i++) {
			padding += PADDING;
		}
 
		formatted += padding + node + '\r\n';
		pad += indent;
	});
 
	return formatted;
};

$(document).ready(function(){
	var menu= formatJson('${menu}')
    
    console.log(menu)
    $("#menu").html(menu);
	
	$("#del").click(function(){
		if(window.confirm('你确定删除吗？')){
			location.href= '<%=request.getContextPath() %>/console/wxmanage/deleteMenu'
         }
    });
});
</script>
</head>
<body>
	<a href="<%=request.getContextPath() %>/console/wxmanage/getSelfMenu">获取自定义菜单配置(selfmenu)</a>
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<a href="<%=request.getContextPath() %>/console/wxmanage/getMenu">自定义菜单查询(menu/get)</a>
	
	<br>
	<form action="<%=request.getContextPath() %>/console/wxmanage/setMenu" method="post" >
		<textarea id="menu" name="menu" rows="30" cols="80"></textarea>
		<br>
		<input type="submit" style="margin-top: 10px;" value="自定义菜单创建(menu/create)" >
		 ---- 
		<input type="button" style="margin-top: 10px;" value="自定义菜单删除(menu/delete)" id="del">
	</form>
	<br>
	<a href="http://mp.weixin.qq.com/wiki/10/0234e39a2025342c17a7d23595c6b40a.html" target="_blank">新增说明</a>
</body>
</html>